<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Form 表单 | MyUI 4.x</title>
    <meta name="generator" content="VuePress 1.5.0">
    <link rel="icon" href="/my/favicon.ico">
    <script>
      var _hmt = _hmt || [];
      (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?c4e5f73318b5cb0c389e3d9a05f831cc";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();
    </script>
    <meta name="description" content="MyUI是美亚柏科旗下新德汇出品的Web前端一站式项目工程框架，专注于公检法行业中台系统快速搭建，框架已在多个项目实战检验。">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <link rel="preload" href="/my/assets/css/0.styles.3b7da768.css" as="style"><link rel="preload" href="/my/assets/js/app.145deadf.js" as="script"><link rel="preload" href="/my/assets/js/546.c48d7d92.js" as="script"><link rel="preload" href="/my/assets/js/1382.8b26e840.js" as="script"><link rel="preload" href="/my/assets/js/1234.a1f8d133.js" as="script"><link rel="preload" href="/my/assets/js/974.ffa6c050.js" as="script">
    <link rel="stylesheet" href="/my/assets/css/0.styles.3b7da768.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/my/" class="home-link router-link-active"><img src="/my/img/logo.png" alt="MyUI 4.x" class="logo"> <span class="site-name can-hide">MyUI 4.x</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/my/guide/" class="nav-link">
  指南
</a></div><div class="nav-item"><a href="/my/ui/components/" class="nav-link router-link-active">
  组件
</a></div><div class="nav-item"><a href="/my/ui/charts/" class="nav-link">
  图表
</a></div><div class="nav-item"><a href="/my/ui/map/" class="nav-link">
  地图
</a></div><div class="nav-item"><a href="/my/ui/go/" class="nav-link">
  关系图
</a></div><div class="nav-item"><a href="/my/ui/icon/" class="nav-link">
  图标
</a></div><div class="nav-item"><a href="/my/ui/pages/" class="nav-link">
  页面
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="JSDoc" class="dropdown-title"><span class="title">JSDoc</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/my/api/components.html" class="nav-link">
  基础组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/utils.html" class="nav-link">
  工具函数
</a></li><li class="dropdown-item"><!----> <a href="/my/api/charts.html" class="nav-link">
  图表组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/map.html" class="nav-link">
  地图组件
</a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/my/guide/" class="nav-link">
  指南
</a></div><div class="nav-item"><a href="/my/ui/components/" class="nav-link router-link-active">
  组件
</a></div><div class="nav-item"><a href="/my/ui/charts/" class="nav-link">
  图表
</a></div><div class="nav-item"><a href="/my/ui/map/" class="nav-link">
  地图
</a></div><div class="nav-item"><a href="/my/ui/go/" class="nav-link">
  关系图
</a></div><div class="nav-item"><a href="/my/ui/icon/" class="nav-link">
  图标
</a></div><div class="nav-item"><a href="/my/ui/pages/" class="nav-link">
  页面
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="JSDoc" class="dropdown-title"><span class="title">JSDoc</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/my/api/components.html" class="nav-link">
  基础组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/utils.html" class="nav-link">
  工具函数
</a></li><li class="dropdown-item"><!----> <a href="/my/api/charts.html" class="nav-link">
  图表组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/map.html" class="nav-link">
  地图组件
</a></li></ul></div></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>功能辅助</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>基础元件</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>排版布局</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>容器修饰</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>导航菜单</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>数据录入</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/my/ui/components/cron.html" class="sidebar-link">Cron 表达式</a></li><li><a href="/my/ui/components/edit-tags.html" class="sidebar-link">EditTags 标签编辑（批量输入）</a></li><li><a href="/my/ui/components/editor.html" class="sidebar-link">Editor 富文本编辑器</a></li><li><a href="/my/ui/components/filter.html" class="sidebar-link">Filter 筛选条件表单</a></li><li><a href="/my/ui/components/form.html" aria-current="page" class="active sidebar-link">Form 表单</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/my/ui/components/form.html#代码示例" class="sidebar-link">代码示例</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/my/ui/components/form.html#基础用法" class="sidebar-link">基础用法</a></li><li class="sidebar-sub-header"><a href="/my/ui/components/form.html#初始化数据" class="sidebar-link">初始化数据</a></li><li class="sidebar-sub-header"><a href="/my/ui/components/form.html#布局排版" class="sidebar-link">布局排版</a></li><li class="sidebar-sub-header"><a href="/my/ui/components/form.html#验证" class="sidebar-link">验证</a></li><li class="sidebar-sub-header"><a href="/my/ui/components/form.html#可折叠" class="sidebar-link">可折叠</a></li><li class="sidebar-sub-header"><a href="/my/ui/components/form.html#字典数据" class="sidebar-link">字典数据</a></li><li class="sidebar-sub-header"><a href="/my/ui/components/form.html#数据加载函数" class="sidebar-link">数据加载函数</a></li><li class="sidebar-sub-header"><a href="/my/ui/components/form.html#动态表单" class="sidebar-link">动态表单</a></li><li class="sidebar-sub-header"><a href="/my/ui/components/form.html#事件" class="sidebar-link">事件</a></li></ul></li></ul></li><li><a href="/my/ui/components/form-item.html" class="sidebar-link">FormItem 表单项</a></li><li><a href="/my/ui/components/range.html" class="sidebar-link">Range 范围输入框</a></li><li><a href="/my/ui/components/tag-input.html" class="sidebar-link">TagInput 标签输入框</a></li><li><a href="/my/ui/components/tag-select.html" class="sidebar-link">TagSelect 标签选择器</a></li><li><a href="/my/ui/components/tree-select.html" class="sidebar-link">TreeSelect 下拉树</a></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>数据展示</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>动画效果</span> <span class="arrow right"></span></p> <!----></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="form-表单"><a href="#form-表单" class="header-anchor">#</a> Form 表单</h1> <a href="/my/api/components.html?url=%2Fmy%2Fapi%2Fcomponents%2Fmodule-%24ui_components_my-form.html" target="_blank" data-v-3de95506>MyFrom <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound" data-v-3de95506 data-v-3de95506><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a>  是组件库的重要组成部分，
<p>它是一个表单项的容器，用来收纳<a href="/my/ui/components/form-item.html">表单项组件</a>，提供排版、验证和数据处理功能。</p> <h2 id="代码示例"><a href="#代码示例" class="header-anchor">#</a> 代码示例</h2> <h3 id="基础用法"><a href="#基础用法" class="header-anchor">#</a> 基础用法</h3> <p>MyFrom继承 el-form的全部参数和事件。用法与el-from有差别， el-from需要与el-form-item结合使用。
MyForm不需要显式调用，表单项组件内置了el-form-item， 不需要显式调用。</p> <!----><h3 id="初始化数据"><a href="#初始化数据" class="header-anchor">#</a> 初始化数据</h3> <p>通过设置 <code>model</code> 属性回填表单数据</p> <!----><h3 id="布局排版"><a href="#布局排版" class="header-anchor">#</a> 布局排版</h3> <p>与排版和外观相关的参数包括：
<code>itemWidth</code>、<code>footerAlign</code>、<code>inline</code>、
<code>labelWidth</code>、<code>labelPosition</code>、<code>size</code>、
<code>submitText</code>、<code>submittingText</code>、<code>resetText</code>、<code>footerBlock</code>、
<code>footerExpandBlock</code>、<code>footerFloat</code></p> <!----><h3 id="验证"><a href="#验证" class="header-anchor">#</a> 验证</h3> <p>可以在MyForm或表单项组件配置<code>rules</code>实现验证，用法与el-form、el-form-item一样</p> <!----><h3 id="可折叠"><a href="#可折叠" class="header-anchor">#</a> 可折叠</h3> <p>设置 <code>collapsible</code> 可以实现折叠表单项，常用在筛选条件多的时候，把次要的折叠起来，节省空间。</p> <!----><h3 id="字典数据"><a href="#字典数据" class="header-anchor">#</a> 字典数据</h3> <p>通过<code>dictMap</code>设置静态字典数据</p> <!----><h3 id="数据加载函数"><a href="#数据加载函数" class="header-anchor">#</a> 数据加载函数</h3> <!----><h3 id="动态表单"><a href="#动态表单" class="header-anchor">#</a> 动态表单</h3> <!----><h3 id="事件"><a href="#事件" class="header-anchor">#</a> 事件</h3> <p>支持的事件包括： <code>submit</code>、<code>reset</code>、<code>change</code>、<code>collapse</code></p> <!----></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
      ←
      <a href="/my/ui/components/filter.html" class="prev">
        Filter 筛选条件表单
      </a></span> <span class="next"><a href="/my/ui/components/form-item.html">
        FormItem 表单项
      </a>
      →
    </span></p></div> </main></div><div class="global-ui"></div></div>
    <script src="/my/assets/js/app.145deadf.js" defer></script><script src="/my/assets/js/546.c48d7d92.js" defer></script><script src="/my/assets/js/1382.8b26e840.js" defer></script><script src="/my/assets/js/1234.a1f8d133.js" defer></script><script src="/my/assets/js/974.ffa6c050.js" defer></script>
  </body>
</html>
